/*
 * @Author: 17607638761 2856491026@qq.com
 * @Date: 2023-05-16 11:35:13
 * @LastEditors: 17607638761 2856491026@qq.com
 * @LastEditTime: 2023-05-18 09:57:39
 * @FilePath: \bpm-ui\src\main.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { createApp } from 'vue';
// pinia插件-数据持久化
import PiniaPluginPersistedstate from 'pinia-plugin-persistedstate';
// 路由
import router from '@/router';
// ElementPlus
import ElementPlus from 'element-plus';

// global css

import '@/styles/index.scss';

// ElementPlus中文支持
// import locale from 'element-plus/lib/locale/lang/zh-cn';
import locale from 'element-plus/dist/locale/zh-cn.mjs';
// ElementPlus icon
import * as ElementPlusIconsVue from '@element-plus/icons-vue';
// Echarts
import echarts from '@/echarts';
// 加载权限
import '@/router/permission';
// 入口文件
import App from '@/App.vue';

// 自定义指令
import directive from './directive';
// 注册指令
import plugins from './plugins';

// svg图标
import 'virtual:svg-icons-register';
import SvgIcon from '@/components/SvgIcon/index.vue';
// 公共组件
import YdForm from '@/components/YdForm/index.vue';
import YdTable from '@/components/YdTable/index.vue';
import YdCard from '@/components/YdCard/index.vue';

import 'default-passive-events';

// 创建Pinia
import { createPinia } from 'pinia';
const pinia = createPinia();
pinia.use(PiniaPluginPersistedstate);

import { validatenull } from './utils/validate';
import { checkPermi } from '@/utils/auth';
import { addDateRange } from './utils/common';
// 创建app
const app = createApp(App);
app.use(pinia);
app.use(router);
app.use(plugins);
app.use(ElementPlus, { locale: locale, size: 'default', zIndex: 2000 });
// 全局变量
app.config.globalProperties.$echarts = echarts;
app.config.globalProperties.$validatenull = validatenull;
app.config.globalProperties.checkPermi = checkPermi;
app.config.globalProperties.addDateRange = addDateRange;

// 注册图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
	app.component(key, component);
}

// 全局挂载
app.component('SvgIcon', SvgIcon);
app.component('YdForm', YdForm);
app.component('YdTable', YdTable);
app.component('YdCard', YdCard);

directive(app);
app.mount('#app');
